#!/bin/bash
# 设置时区
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc --utc
# 本地化
sed -i 's/#zh_CN.UTF-8/zh_CN.UTF-8/g' /etc/locale.gen
sed -i 's/#en_US.UTF-8/en_US.UTF-8/g' /etc/locale.gen
locale-gen
cat << EOF > /etc/locale.conf
LANG=en_US.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_MONETARY=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_NUMERIC=zh_CN.UTF-8
LC_PAPER=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
EOF


# 设置网络 
echo Arch > /etc/hostname
cat << EOF >> /etc/hosts
127.0.0.1	localhost.localdomain	localhost
::1	localhost.localdomain	localhost
127.0.1.1	Arch.localdomain	Arch
EOF


# 添加archlinuxcn 源
cat << 'EOF' >> /etc/pacman.conf
### 清华大学 (ipv4, ipv6, http, https)
[archlinuxcn]
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch
EOF
# 更新系统
pacman -Syyu --noconfirm
# 安装 软件
pacman -S vim git openssh sudo grub networkmanager bash-completion wqy-zenhei wqy-microhei  open-vm-tools  gtkmm3 fuse3 \
    deepin deepin-extra xf86-input-vmmouse xf86-video-vmware  mesa --noconfirm
# 启动加载器的配置 
grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
# 设置sudo
sed -i 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g' /etc/sudoers

# 启动一些必要服务
systemctl enable NetworkManager
systemctl enable sshd
systemctl enable vmtoolsd.service
systemctl enable vmware-vmblock-fuse.service

echo "mkdir share dir"
mkdir /share
cat << EOF >> /etc/fstab
.host:/     /share     fuse.vmhgfs-fuse        nofail,allow_other 0 0
EOF

echo "set root passwd"
passwd
useradd  -m -G wheel jko
cat << EOF >> /home/jko/.bashrc
export LANG="zh_CN.UTF-8";
export LANGUAGE="zh_CN";
EOF
echo "set jko passwd"
passwd jko


